package demo;

import helloword.MyService;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.server.TThreadedSelectorServer;
import org.apache.thrift.transport.*;

public class AsyncServer {

    public static void main(String[] args) throws TTransportException {

        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(8080);
        TThreadedSelectorServer.Args serverArgs = new TThreadedSelectorServer.Args(serverTransport);
        MyAsyncHandler myAsyncHandler = new MyAsyncHandler();
        //方法的调用handler对象过程封装到了ProcessFunction对象中 iface中定义了几个方法就会有几个ProcessFunction
        MyService.AsyncProcessor<MyAsyncHandler> myHandlerProcessor = new MyService.AsyncProcessor<>(myAsyncHandler);
        serverArgs.processor(myHandlerProcessor);
        TThreadedSelectorServer selectorServer = new TThreadedSelectorServer(serverArgs);
        selectorServer.serve();

    }
}
